<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class Shifting_Model extends CI_Model {
	
	private $table= 'shifting_schedules';
	function __construct() {
		parent::__construct();
	}
	
	function getShiftId ($userId, $date = null){
		if($date == null) $date = date('Y-m-d');
		//$this->db->select('*');
		//$this->db->from('shifts');
		//$this->db->join('shifting_schedules', 'shifts.id = shifting_schedules.id');

    	$query = $this->db->get_where($this->table, array('`date_from` <=' => $date,'`date_to` >=' => $date, 'user_id'=>$userId),1);
    	$result = $query->result();
    	return !empty($result)?$result[0]->shift_id:false;
	}

}